/**
 * Created by 97203 on 2018/06/08.
 */
$(function () {
    var permission_datagrid = $("#permission_datagrid");
    permission_datagrid.datagrid({
        url: '/permission/query.do',
        fitColumns: true,
        fit: true,
        pagination: true,    //分页条
        rownumbers: true,     //行号列
        singleSelect: true,
        toolbar: '#tb',
        columns: [[
            {field: 'name', title: '权限名称', width: 100},
            {field: 'resource', title: '权限编号', width: 100},
        ]]
    })

    var methodObj = {
        reload: function () {
            permission_datagrid.datagrid('reload');
        },
        loadPermission:function () {
            $.messager.confirm('确认对话框', '您想要执行操作吗？', function (r) {
                if(r){
                    $.get('/permission/reload.do', function (data) {
                        if (data.success) {
                            $.messager.alert('温馨提示', '操作成功！', 'info', function () {
                                permission_datagrid.datagrid('reload');
                            });
                        } else {
                            $.messager.alert('温馨提示', data.msg, 'warning');
                        }
                    })
                }
            });
        }
    }
    $("a[data-cmd]").click(function () {
        //获取按钮上的data-cmd的值
        var methodName = $(this).data("cmd");
        methodObj[methodName]();
    })
})
